<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>登研讨天地</title>
    <link rel="icon" href="">
	<link rel="stylesheet" type="text/css" href="/static/css/aui.css" />
	<link rel="stylesheet" type="text/css" href="/static/css/aui-slide.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/aui-pull-refresh.css" />
    <style type="text/css">
        .hw-overlay{display:none; position: fixed; top:0;left:0;width:100%;height:100%; background-color: rgba(0,0,0,0.3);z-index:10;} 
        .hw-layer-wrap{box-sizing:border-box; width:570px; position:absolute;left:50%;top:50%; margin-left:-285px; border-radius:3px; background-color:#fff; box-shadow:1px 2px 4px 0 rgba(0,0,0,0.12); padding:45px 50px;} 
        .hwLayer-close{position:absolute; right:20px; top:20px; width:20px; height:20px; cursor:pointer; font-size:20px; color:#ccc;} 
        .hw-layer-wrap .hw-icon{color:#b4d8f3;font-size:86px;text-align:center;} 
        .hw-layer-wrap h4{margin:5px 0 30px; font-size:24px; color:#383c3e;} 
        .hw-layer-wrap p{margin:30px 0; line-height:22px; color:#595d60; text-align:left;} 
         
        @media (max-width:768px){ 
            .hw-layer-wrap{width:350px; margin-left:-175px; margin-top:-200px; padding:20px 0px; text-align:center;} 
        } 
        @media (max-width:400px){ 
            .hw-layer-wrap{width:250px; margin-left:-125px;padding:20px 0px;} 
        }
    .aui-refresh-pull-arrow{
        background-image: url('data:image/svg+xml;charset=utf-8,<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><path d="M99.225 3.528c8.34 0 15.104 6.763 15.104 15.105 0 8.34-6.766 15.105-15.105 15.105-8.342 0-15.105-6.763-15.105-15.105S90.883 3.528 99.225 3.528zM76.567 48.843h45.315c4.17 0 7.552 3.38 7.552 7.552v5.035c0 4.172-3.382 7.552-7.552 7.552H76.567c-4.172 0-7.553-3.38-7.553-7.552v-5.035c0-4.172 3.38-7.552 7.553-7.552zm-10.07 35.245h65.455c4.17 0 7.552 3.38 7.552 7.552v5.035c0 4.172-3.382 7.552-7.552 7.552H66.497c-4.172 0-7.553-3.38-7.553-7.552V91.64c0-4.172 3.38-7.552 7.553-7.552zm8.044 87.596c-20.397-23.16-45.805-52.352-45.805-52.352h140.98s-25.146 28.735-45.4 51.884c-33.454 38.234-18.118 36.4-49.774.468z" fill="#27AE60" class="transform-group"/></svg>')
    }
    </style>
</head>
<body>
<div id="content">
    <header class="aui-bar aui-bar-nav" id="header" style="background-color: #27AE60;padding-top:12px; ">
        <div class="aui-title">研讨天地</div>
        <a class="btn aui-btn aui-pull-right show-layer" data-show-layer="hw-layer" role="button">
            <span class="aui-iconfont aui-icon-plus"></span>
        </a>

    </header>
    <!-- 内容 -->
    <section class="aui-refresh-content" style="padding-bottom: 48px;">
        <ul class="aui-list aui-media-list" id="demo">
        {% for learn in learns %}
            {% if learn.images %}
            <a href="{% url 'mycampus:content_learn' learn.id %}">
            <li class="aui-list-item">
                <div class="aui-media-list-item-inner">
                    <div class="aui-list-item-media">
                        <img src="/static/{{learn.images}}" style="height:3.5rem;">
                    </div>
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-text">
                            <div class="aui-list-item-title" style="color:#333;font-size:19px;">{{learn.publisher}}</div>
                        </div>
                        <div class="aui-list-item-text" style="color:#4c5276;">
                            {{learn.title}}
                        </div>
                        <div class="aui-info aui-font-size-12 aui-padded-t-0 aui-padded-b-0">
                            <div class="aui-info-item">{{learn.time|date:"Y-m-d H:i"}}</div>
                            <div class="aui-info-item">
                                <i class="aui-iconfont aui-icon-comment" style="color:#4c5276"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </li>
            </a>
            {% else %}
            <a href="{% url 'mycampus:content_learn' learn.id %}">
            <li class="aui-list-item">
                <div class="aui-media-list-item-inner">
                    <!-- <div class="aui-list-item-media">
                        <img src="/static/{{learn.images}}">
                    </div> -->
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-text">
                            <div class="aui-list-item-title" style="color:#333;font-size:19px;">{{learn.publisher}}</div>
                        </div>
                        <div class="aui-list-item-text" style="color:#4c5276;">
                            {{learn.title}}
                        </div>
                        <div class="aui-info aui-font-size-12 aui-padded-t-0 aui-padded-b-0">
                            <div class="aui-info-item">{{learn.time|date:"Y-m-d H:i"}}</div>
                            <div class="aui-info-item">
                                <i class="aui-iconfont aui-icon-comment" style="color:#4c5276"></i>
                            </div>
                        </div>
                    </div>
                </div>
            </li>
            </a>
            {% endif %}
        {% endfor %}
        </ul>
    </section>

    <footer class="aui-bar aui-bar-tab" id="footer" style="background-color: #27AE60">
	    <div class="aui-bar-tab-item" tapmode>
	        <i class="aui-iconfont aui-icon-home"></i>
	        <div class="aui-bar-tab-label"><a href="{% url 'mycampus:index' %}" style="color: #000">首页</a></div>
	    </div>
	    <div class="aui-bar-tab-item aui-active" tapmode>
	        <i class="aui-iconfont aui-icon-calendar"></i>
	        <div class="aui-bar-tab-label"><a href="" style="color: #000">学习</a></div>
	    </div>
	    <div class="aui-bar-tab-item" tapmode>
	        <i class="aui-iconfont aui-icon-plus"></i>
	        <div class="aui-bar-tab-label"><a href="{% url 'mycampus:published' %}" style="color: #000">发表</a></div>
	    </div>
	    <div class="aui-bar-tab-item" tapmode>
	        <i class="aui-iconfont aui-icon-like"></i>
	        <div class="aui-bar-tab-label"><a href="{% url 'mycampus:love' %}" style="color: #000">love</a></div>
	    </div>
	    <div class="aui-bar-tab-item" tapmode>
	        <div class="aui-dot"></div>
	        <i class="aui-iconfont aui-icon-my"></i>
	        <div class="aui-bar-tab-label"><a href="{% url 'mycampus:user' %}" style="color: #000">我的</a></div>
	    </div>
	</footer>
    <!-- 发表弹出框 -->
    <div class="hw-overlay" id="hw-layer"> 
        <div class="hw-layer-wrap"> 
            <div class="aui-card-list">
                <form role="form" action="{% url 'mycampus:send_learn' %}" method="post" enctype="multipart/form-data" onsubmit="return check()">
                    {% csrf_token %}
                    <div class="aui-card-list-header">
                        <input type="file" name="image" onchange="imgPreview(this)" />
                    </div>
                    <div class="aui-card-list-content-padded">
                        <img id="preview" /><br/>
                        <textarea id="title" placeholder="标题..." name="title" onblur="cheack_title()"></textarea>
                        </span><span id="erroretitle" style="display:none;color:red;">标题不能为空！</span>
                        <textarea id="content" placeholder="研讨天地..." name="content"></textarea>
                       <!--  </span><span id="errorcontent" style="display:none;color:red;">内容不能为空！</span> -->
                    </div>
                    <div class="aui-card-list-footer">
                          <!-- <div class="aui-btn aui-btn-primary" type="submit" id="send">发表</div> -->
                          <!-- <button type="submit" class="btn btn-primary block full-width m-b">注 册</button> -->
                        <button type="submit" type="button" class="aui-btn aui-btn-primary  hwLayer-ok">发表</button>
                        <!-- <button class="btn btn-success hwLayer-ok">确 定</button>  -->
                        <!-- <button class="aui-btn aui-btn-primary hwLayer-cancel">取 消</button>  -->
                    </div>
                </from>
            </div> 
        </div> 
    </div> 
</div>
    <script type="text/javascript" src="/static/js/api.js"></script>
    <script type="text/javascript" src="/static/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/static/js/newcommon.js"></script>
    <script type="text/javascript" src="/static/js/aui-pull-refresh.js"></script>
    <script type="text/javascript">
        apiready = function(){
                if(api.systemType == 'ios'){
                    scaleEnabled = true;
                    // document.getElementById('header').style.paddingTop = '10px';
                }
                //支持沉浸式效果
                if (!api.statusBarAppearance) {
                   document.getElementById('header').style.paddingTop = '0px';
                }
            };
        function cheack_title(){
            var title = document.getElementById('title').value;
            if (title == '' || title==undefined ||title==null|| content == ''||content==undefined||content==null) {
            document.getElementById('erroretitle').style.display = "block";
            return false;
            }
            else{
                document.getElementById('erroretitle').style.display = "none";
                return true;
            }
        }
        function check(){
            if(!cheack_title()){
                return false;
            }
            else{
                return true;
            }
        }
    </script>
    <!-- 下拉刷新 -->
    <script type="text/javascript">
        var count=4;
        var pullRefresh = new auiPullToRefresh({
            container: document.querySelector('.aui-refresh-content'),
            triggerDistance: 100
        },function(ret){
            if(ret.status=="success"){
                setTimeout(function(){
                    var j=0;
                    // var urls = 'mycampus:content_learn';
                    var urls = '/mycampus/content_learn/';
                    $.getJSON("{% url 'mycampus:learn_refresh' %}",{'a':count},function(item){
                        //返回值 ret 在这里是一个列表 把 ret 的每一项显示在网页上
                        var wrap = document.getElementById("demo")
                        // var lis = wrap.querySelectorAll('.aui-card-list');
                        for (var i = 0, length = 4; i < length; i++,j++) {
                            var date1 = item[j][5].substr(0,10);
                            var date2 = item[j][5].substr(11,5);
                            if(item[j][4])
                                var html ='<a href="'+urls+item[j][0]+'" >'
                                                +'<li class="aui-list-item">'
                                                    +'<div class="aui-media-list-item-inner">'
                                                        +'<div class="aui-list-item-media">'
                                                            +'<img src="/static/'+item[j][4]+'" style="height:3.5rem;">'
                                                        +'</div>'
                                                        +'<div class="aui-list-item-inner">'
                                                            +'<div class="aui-list-item-text">'
                                                                +'<div class="aui-list-item-title" style="color:#333;font-size:19px;">'+item[j][1]
                                                                +'</div>'
                                                            +'</div>'
                                                            +'<div class="aui-list-item-text" style="color:#4c5276;">'
                                                                +item[j][2]
                                                            +'</div>'
                                                            +'<div class="aui-info aui-font-size-12 aui-padded-t-0 aui-padded-b-0">'
                                                                +'<div class="aui-info-item">'+date1+' '+date2+'</div>'
                                                                +'<div class="aui-info-item">'
                                                                    +'<i class="aui-iconfont aui-icon-comment" style="color:#4c5276"></i>'
                                                                +'</div>'
                                                            +'</div>'
                                                        +'</div>'
                                                    +'</div>'
                                                +'</li>'
                                            +'</a>';
                            else
                                var html ='<a href="'+urls+item[j][0]+'" >'
                                                +'<li class="aui-list-item">'
                                                    +'<div class="aui-media-list-item-inner">'
                                                        +'<div class="aui-list-item-inner">'
                                                            +'<div class="aui-list-item-text">'
                                                                +'<div class="aui-list-item-title" style="color:#333;font-size:19px;">'+item[j][1]
                                                                +'</div>'
                                                            +'</div>'
                                                            +'<div class="aui-list-item-text" style="color:#4c5276;">'
                                                                +item[j][2]
                                                            +'</div>'
                                                            +'<div class="aui-info aui-font-size-12 aui-padded-t-0 aui-padded-b-0">'
                                                                +'<div class="aui-info-item">'+date1+' '+date2+'</div>'
                                                                +'<div class="aui-info-item">'
                                                                    +'<i class="aui-iconfont aui-icon-comment" style="color:#4c5276"></i>'
                                                                +'</div>'
                                                            +'</div>'
                                                        +'</div>'
                                                    +'</div>'
                                                +'</li>'
                                            +'</a>';
                            wrap.insertAdjacentHTML('afterbegin', html);
                        }
                        count =count+j;
                        // }
                        
                    })
                    pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                },1500)
            }
        })
    </script>
</body>
</html>